# 猜数字游戏
# 每次输入四位数字，无间隔
# 数字及位数均正确记A，数字正确位置不对记B
import random as r
rBase = '1234567890'
rSet = r.sample(rBase, 4)
for n in range(8):
    a, b = 0, 0
    rGuess = input("请输入第{}次猜想：".format(n+1))
    for i in range(len(rGuess)):
        for j in range(len(rSet)):
            if rGuess[i] == rSet[j]:
                if i == j:
                    a += 1
                else:
                    b += 1
    if a == 4:
        print("恭喜你！完全正确")
        break
    print("本次猜测：{}A {}B".format(a, b))
else:
    print("正确答案是：", rSet, "愚蠢的人类！")
print("游戏结束")
